﻿using System;
using System.Text;
using System.Threading;
using Mono.Cecil.Metadata;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x0200006E RID: 110
	public sealed class GenericInstanceType : TypeSpecification, IGenericInstance, IMetadataTokenProvider, IGenericContext
	{
		// Token: 0x170000CA RID: 202
		// (get) Token: 0x06000474 RID: 1140 RVA: 0x0001C344 File Offset: 0x0001A544
		public bool HasGenericArguments
		{
			get
			{
				return !this.arguments.IsNullOrEmpty<TypeReference>();
			}
		}

		// Token: 0x170000CB RID: 203
		// (get) Token: 0x06000475 RID: 1141 RVA: 0x0001C364 File Offset: 0x0001A564
		public Collection<TypeReference> GenericArguments
		{
			get
			{
				bool flag = this.arguments == null;
				if (flag)
				{
					Interlocked.CompareExchange<Collection<TypeReference>>(ref this.arguments, new Collection<TypeReference>(), null);
				}
				return this.arguments;
			}
		}

		// Token: 0x170000CC RID: 204
		// (get) Token: 0x06000476 RID: 1142 RVA: 0x0001C39C File Offset: 0x0001A59C
		// (set) Token: 0x06000477 RID: 1143 RVA: 0x00003BD0 File Offset: 0x00001DD0
		public override TypeReference DeclaringType
		{
			get
			{
				return base.ElementType.DeclaringType;
			}
			set
			{
				throw new NotSupportedException();
			}
		}

		// Token: 0x170000CD RID: 205
		// (get) Token: 0x06000478 RID: 1144 RVA: 0x0001C3BC File Offset: 0x0001A5BC
		public override string FullName
		{
			get
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append(base.FullName);
				this.GenericInstanceFullName(stringBuilder);
				return stringBuilder.ToString();
			}
		}

		// Token: 0x170000CE RID: 206
		// (get) Token: 0x06000479 RID: 1145 RVA: 0x0000A3A0 File Offset: 0x000085A0
		public override bool IsGenericInstance
		{
			get
			{
				return true;
			}
		}

		// Token: 0x170000CF RID: 207
		// (get) Token: 0x0600047A RID: 1146 RVA: 0x0001C3F0 File Offset: 0x0001A5F0
		public override bool ContainsGenericParameter
		{
			get
			{
				return this.ContainsGenericParameter() || base.ContainsGenericParameter;
			}
		}

		// Token: 0x170000D0 RID: 208
		// (get) Token: 0x0600047B RID: 1147 RVA: 0x0001C414 File Offset: 0x0001A614
		IGenericParameterProvider IGenericContext.Type
		{
			get
			{
				return base.ElementType;
			}
		}

		// Token: 0x0600047C RID: 1148 RVA: 0x00003BD8 File Offset: 0x00001DD8
		public GenericInstanceType(TypeReference type) : base(type)
		{
			base.IsValueType = type.IsValueType;
			this.etype = Mono.Cecil.Metadata.ElementType.GenericInst;
		}

		// Token: 0x0600047D RID: 1149 RVA: 0x00003BF8 File Offset: 0x00001DF8
		internal GenericInstanceType(TypeReference type, int arity) : this(type)
		{
			this.arguments = new Collection<TypeReference>(arity);
		}

		// Token: 0x04000122 RID: 290
		private Collection<TypeReference> arguments;
	}
}
